/**
 * Project: TacticaPescaditos
 * File: Dribble.java
 */
package org.javahispano.javacup.tacticas_aceptadas.Pescaditos.com.chidotronics.javacup.fsm.state;

import org.javahispano.javacup.modelo.Posicion;

import org.javahispano.javacup.tacticas_aceptadas.Pescaditos.com.chidotronics.javacup.Ball;
import org.javahispano.javacup.tacticas_aceptadas.Pescaditos.com.chidotronics.javacup.GoalKeeper;
import org.javahispano.javacup.tacticas_aceptadas.Pescaditos.com.chidotronics.javacup.TeamPlayer;
import org.javahispano.javacup.tacticas_aceptadas.Pescaditos.com.chidotronics.javacup.geometrics.Vector2D;
import org.javahispano.javacup.tacticas_aceptadas.Pescaditos.com.chidotronics.javacup.messages.Telegram;

/**
 * @author Carlos Alberto
 * class: InterceptPass
 */
public class InterceptPass implements State<TeamPlayer> {
	
	private String name;

	/**
	 * 
	 */
	private InterceptPass() {
		this.name = "InterceptPass";
	}

	public static final State<TeamPlayer> instance = new InterceptPass();

	public void enter(TeamPlayer player) {		
		player.getSteering().interceptOn();	
	}

	public void execute(TeamPlayer player) {

		if (!player.getTactica().isControlling() && 
				player.isClosestToTrajectory() ) {


			if (player.canKick()){
				player.getStateMachine().changeState(KickBall.instance);	
				return;
			}


		} else {
			player.getStateMachine().changeState(Wait.instance);
		}


	}

	public void exit(TeamPlayer player) {
		player.getSteering().interceptOff();	
		
	}

	public boolean onMessage(TeamPlayer o, Telegram telegram) {
		return false;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		return this.name.hashCode();
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return this.name;
	}
}
